package test.my.com.myapplicationtest.utils;

import android.content.Context;
import android.widget.Toast;

import test.my.com.myapplicationtest.MyApplication;

/**
 * Author : Cooper
 * Time : 2016/9/14  14:18
 * Description : 对Toast封装
 */
public class ToastUtil {

    private static Toast toast;

    private static Toast makeToast(String msg,int duration) {
        if (toast == null) {
            toast = Toast.makeText(MyApplication.getApplication(),msg,duration);
        } else {
            toast.setDuration(duration);
            toast.setText(msg);
        }
        return toast;
    }

    public static void showToast(String msg) {
        makeToast(msg,Toast.LENGTH_SHORT).show();
    }

    public static void showToastLong(String msg) {
        makeToast(msg,Toast.LENGTH_LONG).show();
    }

    public static void showToastShort(Context context,String msg) {
        makeToast(msg,Toast.LENGTH_SHORT).show();
    }
}
